const electron = require('electron').remote

const BrowserWindow = require('electron').remote.BrowserWindow
const path = require('path');
const url = require('url');

function hello() {
    // console.log(process);
    // console.log(electron.app.getPath('home')); // 获取用户根目录
    // console.log(electron.app.getPath('userData')); // 用于存储 app 用户数据目录
    // console.log(electron.app.getPath('appData')); // 用于存储 app 数据的目录，升级会被福噶
    // console.log(electron.app.getPath('desktop')); // 桌面目录
}
hello();

var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, { 'Content-Type': 'text-plain' });
    response.end('Hello World\n');
}).listen(8124);


const manageWindowBtn = document.getElementById('window-haoyou');
let win;

manageWindowBtn.addEventListener('click', function (event) {
    const modalPath = path.join('file://', __dirname, 'qq.html')
    win = new BrowserWindow({ width: 400, height: 275 })
    win.on('resize', updateReply)
    win.on('move', updateReply)
    win.on('close', function () { win = null })
    win.loadURL(modalPath)
    win.webContents.openDevTools()
    win.show()

    function updateReply() {
        const manageWindowReply = document.getElementById('window-haoyou-reply')
        const message = `大小: ${win.getSize()} - 位置: ${win.getPosition()}`
        manageWindowReply.innerText = message
    }
})